RelationManyList
Abstract base class for a many-relation list backed by IStorage.
Implementa: IRelationManyList<T>, IAsyncCollection<T>, IAsyncEnumerable<T>
Construtores
protected RelationManyList(IStorage storage)
relationManyList = RelationManyList(storage)
Abstract base class for a many-relation list backed by IStorage.
- storage
- The underlying storage provider.
Propriedades
public int BufferSize { get; set; }
value = relationManyList.BufferSize
relationManyList.BufferSize = value
Gets or sets the page size used for batched loading from storage.
public bool BulkLoad { get; set; }
value = relationManyList.BulkLoad
relationManyList.BulkLoad = value
Gets or sets whether the whole list is kept in memory, filled on first access or by CancellationToken).
public bool CacheCount { get; set; }
value = relationManyList.CacheCount
relationManyList.CacheCount = value
Gets or sets whether to cache the entity count.
public IReadOnlyDictionary<TId, TEntity> CachedEntities { get; }
value = relationManyList.CachedEntities
Read-only view of the lazily-built bulk-load cache, keyed by entity identity. Returns when the cache has not been initialised yet (e.g. before the first read on a BulkLoad list). Useful for diagnostics — and lets tests assert on cache state without reaching into private fields.
public TimeSpan CacheTimeOut { get; set; }
value = relationManyList.CacheTimeOut
relationManyList.CacheTimeOut = value
Gets or sets the cache expiration timeout.
public virtual bool IsReadOnly { get; protected set; }
value = relationManyList.IsReadOnly
relationManyList.IsReadOnly = value
Gets or sets whether this list is read-only.
public static Schema Meta { get; }
value = RelationManyList.Meta
Gets the schema metadata for .
public IStorage Storage { get; }
value = relationManyList.Storage
Gets the underlying storage provider.
Métodos
public ValueTask<TEntity> AddAsync(TEntity item, CancellationToken cancellationToken)
result = relationManyList.AddAsync(item, cancellationToken)
Adds a new entity to the list and storage.
public ValueTask ClearAsync(CancellationToken cancellationToken)
result = relationManyList.ClearAsync(cancellationToken)
Removes all entities from the list and storage.
public abstract ValueTask<bool> ContainsAsync(TEntity item, CancellationToken cancellationToken)
result = relationManyList.ContainsAsync(item, cancellationToken)
Determines whether the list contains the specified entity.
public ValueTask CopyToAsync(TEntity[] array, int index, CancellationToken cancellationToken)
result = relationManyList.CopyToAsync(array, index, cancellationToken)
Copies entities to the specified array starting at the given index.
public ValueTask<int> CountAsync(bool deleted, CancellationToken cancellationToken)
result = relationManyList.CountAsync(deleted, cancellationToken)
Gets the count of entities, optionally including deleted ones.
public ValueTask<int> CountAsync(CancellationToken cancellationToken)
result = relationManyList.CountAsync(cancellationToken)
Gets the count of non-deleted entities.
protected virtual IQueryable<TEntity> CreateQueryable()
result = relationManyList.CreateQueryable()
Creates an IQueryable over the list data.
public ValueTask<TEntity[]> GetByKeyAsync<TKey>(Expression<Func<TEntity, TKey>> keySelector, TKey key, CancellationToken cancellationToken)
result = relationManyList.GetByKeyAsync(keySelector, key, cancellationToken)
The held rows grouped by something other than their identity, so a caller asking for "the rows of this owner" is answered by a lookup rather than by walking the whole table.
- keySelector
- Reads the key off a row; it also identifies the grouping, so the same one is built once and reused.
- key
- The key to look up.
- cancellationToken
- Cancellation token.
Retorna: The rows under that key, or an empty array.
public ValueTask<IEnumerable<TEntity>> GetRangeAsync(long startIndex, long count, bool deleted, string sortExpression, ListSortDirection direction, CancellationToken cancellationToken)
result = relationManyList.GetRangeAsync(startIndex, count, deleted, sortExpression, direction, cancellationToken)
Gets a range of entities with paging, sorting, and optional deleted filter.
protected abstract ValueTask<bool> IsSaved(TEntity item, CancellationToken cancellationToken)
result = relationManyList.IsSaved(item, cancellationToken)
Determines whether the specified entity has already been saved to storage.
protected virtual ValueTask<TEntity> OnAdd(TEntity entity, CancellationToken cancellationToken)
result = relationManyList.OnAdd(entity, cancellationToken)
Adds an entity to the underlying storage.
protected virtual ValueTask OnClear(CancellationToken cancellationToken)
result = relationManyList.OnClear(cancellationToken)
Clears all entities from the underlying storage.
protected virtual ValueTask<long> OnGetCount(bool deleted, CancellationToken cancellationToken)
result = relationManyList.OnGetCount(deleted, cancellationToken)
Gets the total count of entities from storage.
protected virtual ValueTask<TEntity[]> OnGetGroup(long startIndex, long count, bool deleted, string orderBy, ListSortDirection direction, CancellationToken cancellationToken)
result = relationManyList.OnGetGroup(startIndex, count, deleted, orderBy, direction, cancellationToken)
Retrieves a page of entities from the underlying storage.
protected virtual ValueTask<bool> OnRemove(TEntity entity, CancellationToken cancellationToken)
result = relationManyList.OnRemove(entity, cancellationToken)
Removes an entity from the underlying storage.
protected virtual ValueTask<TEntity> OnUpdate(TEntity entity, CancellationToken cancellationToken)
result = relationManyList.OnUpdate(entity, cancellationToken)
Updates an entity in the underlying storage.
public Task PreloadAsync(CancellationToken cancellationToken)
result = relationManyList.PreloadAsync(cancellationToken)
Reads the whole list into memory now, when BulkLoad asks for it to be kept there.
public virtual ValueTask<TEntity> ReadById(TId id, CancellationToken cancellationToken)
result = relationManyList.ReadById(id, cancellationToken)
Reads an entity by its identifier.
public ValueTask<bool> RemoveAsync(TEntity item, CancellationToken cancellationToken)
result = relationManyList.RemoveAsync(item, cancellationToken)
Removes the specified entity from the list and storage.
public ValueTask<bool> RemoveById(TId id, CancellationToken cancellationToken)
result = relationManyList.RemoveById(id, cancellationToken)
Removes an entity by its identifier.
public virtual void ResetCache()
relationManyList.ResetCache()
Resets the in-memory cache, forcing data to be reloaded from storage.
public ValueTask<TEntity> SaveAsync(TEntity item, CancellationToken cancellationToken)
result = relationManyList.SaveAsync(item, cancellationToken)
Saves an entity by adding it if new, or updating it if it already exists.
public virtual IQueryable<TEntity> ToQueryable()
result = relationManyList.ToQueryable()
Converts the list to an IQueryable.
public virtual ValueTask<IQueryable<TEntity>> ToQueryableAsync(CancellationToken cancellationToken)
result = relationManyList.ToQueryableAsync(cancellationToken)
Hands the list over as a query, loading it first when it is one that is kept in memory.
- cancellationToken
- Cancellation token.
Retorna: A query over the held copy for a list kept in memory, over the storage for one that is not.
public ValueTask<bool> TryAddAsync(TEntity entity, CancellationToken cancellationToken)
result = relationManyList.TryAddAsync(entity, cancellationToken)
Tries to add an entity, returning false if it already exists.
public ValueTask<TEntity> UpdateAsync(TEntity entity, CancellationToken cancellationToken)
result = relationManyList.UpdateAsync(entity, cancellationToken)
Updates an existing entity in storage.